<?
  $frm['gid'] = intval ($frm['gid']);
  $frm['lid'] = intval ($frm['lid']);
  $q = 'select *
  				, date_format(date_added, \'%b %D, %Y\') as fdate_added
  				, date_format(date_started, \'%b %D, %Y\') as started 
  			from hl_listings where status = 2 and id = ' . $frm['lid'];
  if (!($sth = mysql_query ($q))) {
    exit (mysql_error ());
  }

  $row = mysql_fetch_array ($sth);
  if (!$row) {
   echo 'Invalid listing id';
    exit ();
  }

  $listing = array ();
  $q = 'select * from hl_groups';
  if (!($gsth = mysql_query ($q))) {
    exit (mysql_error ());
  }

  $listings = array ();
  while ($grow = mysql_fetch_array ($gsth)) {
    if ($grow['id'] == $row['group_id']) {
      $listing = $grow;
    }
    array_push ($listings, $grow);
  }

  $row['withdrawal_type'] = ($row['withdrawal_type'] == 1 ? 'Manual' : ($row['withdrawal_type'] == 2 ? 'Instant' : 'Automatic'));
?>  
<form method=post name="approve_form">
<input type="hidden" name="a" value="decline_listing">
<input type="hidden" name="action" value="save">
<input type="hidden" name="lid" value="<?php echo $frm['lid'];?>">
<input type="hidden" name="gid" value="<?php echo $frm['gid'];?>">
<input type="hidden" name="p" value="<?php echo $frm['p'];?>">
<input type="hidden" name="return" value="<?php echo $frm['return'];?>">
<table cellspacing=1 cellpadding=2 border=0 width=100%>
<tr>
 <td width=30%>Name:</td><td>
  <?php echo htmlspecialchars ($row['name']);?>
 </td>
</tr>
<tr>
 <td>Group:</td><td>
  	<?php echo $listing['type'];?>
 </td>
</tr>
<tr>
 <td>URL:</td>
 <td>
 	<?php echo htmlspecialchars ($row['url']);?>
 </td>
</tr>
<tr>
 <td>Percents:</td>
 <td><?php echo htmlspecialchars ($row['percents']);?> </td>
</tr>
<tr>
 <td>Minimal Spend:</td>
 <td><?php echo htmlspecialchars ($row['min_spend']);?></td>
</tr>
<tr>
 <td>Maximal Spend:</td>
 <td><?php echo htmlspecialchars ($row['max_spend']);?></td>
</tr>
<tr>
 <td>Referral:</td>
 <td><?php echo htmlspecialchars ($row['referral']);?></td>
</tr>
<tr>
 <td>Withdrawal:</td>
 <td><?php echo htmlspecialchars ($row['withdrawal_type']);?></td>
</tr>
<tr>
 <td>Contact E-mail:</td>
 <td><a href="mailto:<?php echo htmlspecialchars ($row['email']);?>">
  	<?php echo htmlspecialchars ($row['email']);?>
  </a></td>
</tr>
<tr>
 <td>Support E-mail:</td>
 <td><a href="mailto:<?php echo htmlspecialchars ($row['support_email']);?>">
  	<?php echo htmlspecialchars ($row['support_email']);?>
  </a></td>
</tr>
<tr>
 <td>TG Support Forum:</td>
 <td><a href="<?php echo htmlspecialchars ($row['support_form']);?>">
 	<?php echo htmlspecialchars ($row['support_form']);?>
 </a></td>
</tr>
<tr>
 <td>MMG Support Forum:</td>
 <td><a href="<?php echo htmlspecialchars ($row['support_forum']);?>">
  <?php echo htmlspecialchars ($row['support_forum']);?>
 </a></td>
</tr>
<tr>
 <td>DTM Support Forum:</td>
 <td><?php echo htmlspecialchars ($row['support_aim']);?> </td>
</tr>
<tr>
 <td>Added:</td>
 <td><?php echo $row['fdate_added'];?></td>
</tr>
<tr>
 <td>Started:</td>
 <td><?php echo $row['started'];?></td>
</tr>
<tr>
  <td valign=top>Payment Systems:</td>
  <td><?php echo $row['pay_systems'];?></td>
</tr>
<tr>
 <td>HYIP E-currency accounts:</td>
 <td><?php echo htmlspecialchars ($row['account']);?></td>
</tr>
<tr>
  <td colspan=2>Description:</td>
</tr>
<tr>
  <td colspan=2><?php echo htmlspecialchars ($row['description']);?> </td>
</tr>
</table>
<script>
function chng_status()
{
  var obj = document.approve_form;
  var flag = !obj.send_notification.checked;
  obj.from.disabled = flag;
  obj.to.disabled = flag;
  obj.subject.disabled = flag;
  obj.text.disabled = flag;
}
</script>
<?php 
  $row['group'] = $listing['name'];
  $row['date_added'] = $row['fdate_added'];
  $q = 'select * from hl_emails where id = \'listing_decline\'';
  $sth = mysql_query ($q);
  $email = mysql_fetch_array ($sth);
  $text = $email['text'];
  $subject = $email['subject'];
  reset ($row);
  foreach ($row as $k => $v)
  {
    if (is_array ($v))
    {
      continue;
    }

    $v = strip_tags ($v);
    $v = preg_replace ('' . '/(\\$)/', '\\\\$', $v);
    $text = preg_replace ('' . '/#' . $k . '#/', '' . $v, $text);
    $subject = preg_replace ('' . '/#' . $k . '#/', '' . $v, $subject);
  }

  $text = preg_replace ('/#site_name#/', $settings['site_name'], $text);
  $subject = preg_replace ('/#site_name#/', $settings['site_name'], $subject);
  $text = preg_replace ('/#site_url#/', $settings['site_url'], $text);
  $subject = preg_replace ('/#site_url#/', $settings['site_url'], $subject);
 ?> 
 <table cellspacing=1 cellpadding=2 border=0 width=100%>
 	<tr>
 		<td colspan=2><input type="checkbox" name="send_notification" value="1" checked onclick="chng_status()"> Send Notification?</td>
	</tr>
	<tr>
 		<td>From: </td>
 		<td><input type="text" name="from" value="<?php echo htmlspecialchars ($settings['admin_email']);?>" class=inpts size=50></td>
	</tr>
	<tr>
 		<td>To: </td>
 		<td><input type="text" name="to" value="<?php echo htmlspecialchars ($row['email']);?>" class=inpts size=50></td>
	</tr>
	<tr>
 		<td>Subject: </td>
 		<td><input type="text" name="subject" value="<?php echo htmlspecialchars ($subject);?>" class=inpts size=50></td>
	</tr>
	<tr>
  	<td colspan=2>Message:</td>
	</tr>
	<tr>
  	<td colspan=2><textarea name="text" cols=82 rows=5 class=inpts>
  		<?php echo htmlspecialchars ($text);?>
  	</textarea></td>
</tr>
<tr>
  <td colspan="2"><input style="width: 185px; height: 24px" type="submit" value="Decline & Remove Listing" class=sbmt></td>
</tr>
</table>
</form>
